//
//  TCLYRegisterView.m
//  YuErmuYing
//
//  Created by LYang on 16/9/19.
//  Copyright © 2016年 Tiancheng. All rights reserved.
//

#import "TCLYBabyRegisterView.h"
#import "Macros.h"
#import "Masonry.h"

@implementation TCLYBabyRegisterView
-(instancetype) initWithFrame:(CGRect)frame{
    if (self = [super initWithFrame:frame]) {
        self.imageView = [[UIImageView alloc] init];
        self.imageView.layer.cornerRadius = 50/375.0*screenWidth;
        self.imageView.layer.masksToBounds = YES;
        self.imageView.image = [UIImage imageNamed:@"headerImage"];
        [self addSubview:self.imageView];
        [self.imageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(81/667.0*screenHeight);
            make.centerX.mas_equalTo(self);
            make.width.mas_equalTo(100/375.0*screenWidth);
            make.height.mas_equalTo(100/375.0*screenWidth);
        }];
        self.accountTextField = [[UITextField alloc] init];
        self.accountTextField.placeholder = @"请输入手机号";
        self.accountTextField.textAlignment = NSTextAlignmentCenter;
        self.accountTextField.keyboardType = UIKeyboardTypeNumberPad;
        self.accountTextField.layer.borderWidth = 1;
        self.accountTextField.layer.borderColor = btnColor.CGColor;
        self.accountTextField.layer.cornerRadius = 5;
        [self addSubview:self.accountTextField];
        [self.accountTextField mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.imageView.mas_bottom).offset(65/667.0*screenHeight);
            make.centerX.mas_equalTo(self);
            make.width.mas_equalTo(250/375.0*screenWidth);
            make.height.mas_equalTo(40/667.0*screenHeight);
        }];
        
        self.pwdTextField = [[UITextField alloc] init];
        self.pwdTextField.placeholder = @"请输入密码";
        self.pwdTextField.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
        self.pwdTextField.textAlignment = NSTextAlignmentCenter;
        self.pwdTextField.secureTextEntry = YES;
        self.pwdTextField.layer.borderWidth = 1;
        self.pwdTextField.layer.borderColor = btnColor.CGColor;
        self.pwdTextField.layer.cornerRadius = 5;
        [self addSubview:self.pwdTextField];
        [self.pwdTextField mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.accountTextField.mas_bottom).offset(18/667.0*screenHeight);
            make.centerX.mas_equalTo(self);
            make.width.mas_equalTo(self.accountTextField);
            make.height.mas_equalTo(self.accountTextField);
        }];
        self.againPwdTextField = [[UITextField alloc] init];
        self.againPwdTextField.placeholder = @"请再次输入密码";
        self.againPwdTextField.keyboardType = UIKeyboardTypeNumbersAndPunctuation;
        self.againPwdTextField.textAlignment = NSTextAlignmentCenter;
        self.againPwdTextField.secureTextEntry = YES;
        self.againPwdTextField.layer.borderWidth = 1;
        self.againPwdTextField.layer.borderColor = btnColor.CGColor;
        self.againPwdTextField.layer.cornerRadius = 5;
        
        [self addSubview:self.againPwdTextField];
        [self.againPwdTextField mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.pwdTextField.mas_bottom).offset(18/667.0*screenHeight);
            make.centerX.mas_equalTo(self);
            make.width.mas_equalTo(self.accountTextField);
            make.height.mas_equalTo(self.accountTextField);
        }];
        
        self.loginBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        self.loginBtn.backgroundColor = btnColor;
        [self.loginBtn setTitle:@"注册" forState:UIControlStateNormal];
        self.loginBtn.titleLabel.font = [UIFont systemFontOfSize:14];
        [self.loginBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        self.loginBtn.layer.cornerRadius = 5;
        self.loginBtn.layer.masksToBounds = YES;
        [self addSubview:self.loginBtn];
        [self.loginBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.againPwdTextField.mas_bottom).offset(66/667.0*screenHeight);
            make.centerX.mas_equalTo(self);
            make.width.mas_equalTo(self.accountTextField);
            make.height.mas_equalTo(self.accountTextField);
        }];
        
        self.registerBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.registerBtn setTitle:@"登录在这里哟" forState:UIControlStateNormal];
        [self.registerBtn setTitleColor:btnColor forState:UIControlStateNormal];
        self.registerBtn.titleLabel.font = [UIFont systemFontOfSize:12];
        [self addSubview:self.registerBtn];
        [self.registerBtn mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(self.loginBtn.mas_bottom).offset(16/667.0*screenHeight);
            make.right.mas_equalTo(-12);
            make.height.mas_equalTo(20);
            make.width.mas_equalTo(100);
        }];

    }
    return self;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
